<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理后台 - 库存管理</title>
    <link rel="stylesheet" href="./css/houtai.css">
    <link rel="stylesheet" href="./css/houtai_stock.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
    <!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> -->
    
    <script src="./assets/jquery.min.js"></script>
    <!-- 添加Toast提示框组件 -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css"> 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
</head>
<body>
    <div class="wrapper">
        <!-- 侧边栏 -->
        <aside class="sidebar">
            <div class="logo">
                <h2>超市管理系统</h2>
            </div>
            <ul class="menu">
                <li><a href="./houtai_gzt.html" class="menuItem"><i class="fas fa-tachometer-alt"></i><span>工作台</span></a></li>
                <li><a href="./houtai_user.html" class="menuItem"><i class="fas fa-users"></i><span>用户管理</span></a></li>
                <li><a href="./houtai_product.html" class="menuItem"><i class="fas fa-box"></i><span>商品管理</span></a></li>
                <li><a href="./houtai_order.html" class="menuItem"><i class="fas fa-shopping-cart"></i><span>订单管理</span></a></li>
                <li><a href="./houtai_stock.html" class="menuItem active"><i class="fas fa-warehouse"></i><span>库存管理</span></a></li>
                <li><a href="./houtai_log.html" class="menuItem"><i class="fas fa-history"></i><span>日志记录</span></a></li>
            </ul>
        </aside>

        <!-- 主体部分 -->
        <main class="main-content">
            <header class="header">
                <a id="collapse" href="javascript:void(0)">
                    <i class="fas fa-bars"></i>
                </a>
                <div class="header-title">库存管理</div>
                <div class="user-info">
                    <span id="currentUser">欢迎，管理员</span>
                    <button id="logoutBtn" class="btn-logout">退出</button>
                </div>
            </header>

            <div class="container">
                <!-- 搜索栏 -->
                <div class="search-bar">
                    <div class="search-inputs">
                        <input type="text" id="searchProductName" placeholder="商品名称" />
                        <button id="searchBtn" class="btn-primary">搜索</button>
                        <button id="resetBtn" class="btn-secondary">重置</button>
                        <button id="addBtn" class="btn-success">新增库存</button>
                    </div>
                </div>

                <!-- 库存列表 -->
                <div class="table-container">
                    <table id="stockTable">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>商品名称</th>
                                <th>库存数量</th>
                                <th>锁定库存</th>
                                <th>可用库存</th>
                                <th>创建时间</th>
                                <th>更新时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            <!-- 库存数据将在这里动态插入 -->
                        </tbody>
                    </table>
                </div>

                <!-- 分页 -->
                <div class="pagination" id="pagination">
                    <button id="prevPage" class="btn-page">上一页</button>
                    <div class="page-info">
                        <span id="pageInfo">第 1 页</span>
                        <span id="totalInfo">共 0 条</span>
                    </div>
                    <button id="nextPage" class="btn-page">下一页</button>
                </div>
            </div>

            <!-- 库存表单弹窗 -->
            <div id="stockFormModal" class="modal">
                <div class="modal-content">
                    <div class="modal-header">
                        <h3 id="modalTitle">新增库存</h3>
                        <span class="close">&times;</span>
                    </div>
                    <div class="modal-body">
                        <form id="stockForm">
                            <input type="hidden" id="stockId">
                            <div class="form-group">
                                <label for="productId">商品：</label>
                                <select id="productId" name="productId" required>
                                    <option value="">请选择商品</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <label for="quantity">库存数量：</label>
                                <input type="number" id="quantity" name="quantity" min="0" required>
                            </div>
                            <div class="form-group">
                                <label for="locked">锁定库存：</label>
                                <input type="number" id="locked" name="locked" min="0" required>
                            </div>
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button id="cancelBtn" class="btn-secondary">取消</button>
                        <button id="saveBtn" class="btn-primary">保存</button>
                    </div>
                </div>
            </div>
        </main>
    </div>
    <script src="./js/houtai_stock.js"></script>
</body>
</html>
